package com.example.ByteStream;

import java.io.FileReader;
import java.io.IOException;

/**
 * @author Jason
 * @PACKAGE_NAME com.example.ByteStream
 * @Description 字符输入流FileReader
 * @date 2023-12-11 22:19
 */
public class FileReaderDemo {
    public static void main(String[] args) throws IOException {
        FileReader fr = new FileReader("d:\\aaa.txt");
        //2.读取
        /*int data = 0;
        while ((data = fr.read()) != -1) {//读取一个字符3个字节
            System.out.print((char) data);
        }
        */
        int count = 0;
        char[] buf = new char[1024];
        while ((count = fr.read(buf)) != -1) {
            System.out.println(new String(buf, 0, count));
        }
        //3.关闭
        fr.close();

    }
}
